package br.com.nemesis.jsf.converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

@FacesConverter(value = "conversorCPF")
public class ConversorCPF implements Converter {

    public Object getAsObject(FacesContext fc, UIComponent uic, String valor) {
        if (valor != null && !valor.equals("")) {
           return valor.replaceAll("\\.", "").replaceAll("\\-", "");
        }
        return null;
    }

    public String getAsString(FacesContext fc, UIComponent uic, Object objeto) {
        return (String) objeto;
    }
}
